﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.ProcessManagement
{
    /// <summary>
    /// 工艺结果
    /// </summary>
	[Table("ProcessResults")]

    [Display(Name = "_Model.ProcessResults")]
    public class ProcessResults : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._ProcessResults._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._ProcessResults._Rotue")]
        [Comment("工艺路线")]
        public ProcessRoute Rotue { get; set; }
        [Display(Name = "_Model._ProcessResults._Rotue")]
        [Comment("工艺路线")]
        public long? RotueId { get; set; }
        [Display(Name = "_Model._ProcessResults._Op")]
        [Comment("所属工序")]
        public ProcessRouteItem Op { get; set; }
        [Display(Name = "_Model._ProcessResults._Op")]
        [Comment("所属工序")]
        public long? OpId { get; set; }
        [Display(Name = "_Model._ProcessResults._OpCode")]
        [Comment("工序编码")]
        public string OpCode { get; set; }
        [Display(Name = "_Model._ProcessResults._TagId")]
        [Comment("变量")]
        public long? TagId { get; set; }


        public EquipmentTag Tag { get; set; }   

        [Display(Name = "_Model._ProcessResults._TagName")]
        [Comment("变量名称")]
        public string TagName { get; set; }
        [Display(Name = "_Model._ProcessResults._DataName")]
        [Comment("数据名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string DataName { get; set; }
        [Display(Name = "_Model._ProcessResults._Unit")]
        [Comment("单位")]
        public string Unit { get; set; }
        [Display(Name = "_Model._ProcessResults._UpperLimit")]
        [Comment("上限")]
        [Precision(18,2)]
        public decimal? UpperLimit { get; set; }
        [Display(Name = "_Model._ProcessResults._LowerLimit")]
        [Comment("下限")]
        [Precision(18,2)]
        public decimal? LowerLimit { get; set; }
        [Display(Name = "_Model._ProcessResults._ActiveLimit")]
        [Comment("激活上下限")]
       
        public bool ActiveLimit { get; set; } = false;


        [Display(Name = "_Model._ProcessResults._IntervalSeconds")]
        [Comment("采取频率(秒)")]
        [Range(1, 999999999, ErrorMessage = "Validate.{0}range{1}")]
        public int IntervalSeconds { get; set; } = 0;

        [Display(Name = "_Model._ProcessResults._SampleMode")]
        [Comment("采取方式")]
        public DataSampleEnum SampleMode { get; set; }=DataSampleEnum.SingleData;



        [Display(Name = "_Model._ProcessResults._ProductId")]
        [Comment("产品")]
        public long? ProductId { get; set; }
        [Display(Name = "_Model._ProcessResults._EquipmentId")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }
        [Display(Name = "_Model._ProcessResults._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
